package com.sunny.example.hwrealexame;

import java.awt.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Exame7_相同字母消除法 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String input = scanner.nextLine();
            if (!input.matches("[a-zA-Z]+")) {
                System.out.println(0);
            }

            List<Character> list = input.chars().mapToObj(i -> (char) i).collect(Collectors.toList());
            for (int i = 0; i < list.size(); i++) {
                char c1 = list.get(i);
                if (i + 1 == list.size()) {
                    break;
                }
                char c2 = list.get(i + 1);
                if (c1 == c2) {
                    list.remove(i);
                    list.remove(i);
                    i = 0;//回溯
                }
            }

            if (list.size() > 0) {
                System.out.println(list.size());
            }
        }
    }
}
